In [1]:
%matplotlib notebook
import matplotlib.pyplot as plt
from matplotlib import cm
from astropy.coordinates import SkyCoord
import astropy.units as u
import numpy as np
import ezgal # BC03 model maker
import os
from astropy.cosmology import LambdaCDM
import pandas as pd
In [2]:
# check to make sure we have defined the bpz filter path
if not os.getenv('EZGAL_FILTERS'):
os.environ['EZGAL_FILTERS'] = (f'{os.environ["HOME"]}/Projects/planckClusters/MOSAICpipe/bpz-1.99.3/FILTER/')
def setup_models(zf, tau):
#model = ezgal.model('bc03_exp_0.1_z_0.02_salp.model')
model = ezgal.model('bc03_ssp_z_0.02_salp.model')
if isinstance(tau, list):
raise ValueError('tau cannot be a list')
exp = model.make_exponential(tau)
# set cosmology
exp.set_cosmology(Om=0.3, Ol=0.7, h=0.7, w=-1)
# set the model normalization to Dai et al 2009 (ApJ, 697, 506)
exp.set_normalization('ch1', 0.24, -25.06, vega=True)
exp.add_filter('g_MOSAICII.res', name='g')
exp.add_filter('r_MOSAICII.res', name='r')
exp.add_filter('i_MOSAICII.res', name='i')
exp.add_filter('z_MOSAICII.res', name='z')
exp.add_filter('K_KittPeak.res', name='K')
exp.set_zfs(zf)
return exp
model = setup_models(5, 1)
In [3]:
cosmo = LambdaCDM(H0=70, Om0=0.3, Ode0=0.7, Tcmb0=2.725)
z = np.arange(0.01, 6, 0.01)
dlum = cosmo.luminosity_distance(z)
h = cosmo.H0.value/100
# Calculate some cosmological stuff
DM = cosmo.distmod(z)
dlum = cosmo.luminosity_distance(z)
In [4]:
complete = pd.read_csv('./psz_depths.csv')
In [5]:
complete.describe()
Out[5]:
In [ ]:
In [6]:
Mr_star = -20.44 + 5 * np.log10(h) # abs mag.
Mi_star = -21.22 - 5 * np.log10(h)
#Mi_star = -20.82
# set the normalization
model.set_normalization('r', 0.1, Mr_star, vega=False)
# now we can calculate the corresponding Mstar values in any other band.
# Remember we defined our model (above) to have a zf=5.
# Blanton is defined at z=0.1
filters = ['g', 'r', 'i', 'z', 'K']
mags = np.arange(16, 26, 0.2)
for filter in filters:
Mstar = model.get_absolute_mags(5, filters=filter, zs=0.1)
mstar = (Mstar + DM.value + model.get_kcorrects(5, filters=filter, zs=z) +
model.get_ecorrects(5, filters=filter, zs=z) )
#-
# model.get_ecorrects(5, filters=filter, zs=0.1))
LBCG = 4.0
mstar_sub = mstar - 2.5 * np.log10(0.4)
BCG = mstar - 2.5 * np.log10(LBCG)
# make some plots
plt.figure(figsize=(7, 7 * (np.sqrt(5.) - 1.0) / 2.0))
ax = plt.subplot2grid((1, 4), (0, 0), colspan=2)
axs = plt.subplot2grid((1, 4), (0, 2), colspan=2)
ax.hist(complete[filter].values, bins=mags, color='#348abd',
orientation='horizontal', histtype='stepfilled')
# flip the axis
ax.invert_xaxis()
ax.set_xlabel('$N_{fields}$')
ax.set_ylabel(f'Limiting {filter} Magnitude')
axs.plot(z, mstar_sub, 'k-', linewidth=0.5, label='$0.4L_\star$ galaxy')
axs.plot(z, mstar, 'k-', linewidth=1.5, label='$L_\star$ galaxy')
axs.plot(z, BCG, 'k-', linewidth=2.5, label='$%dL_\star$ (BCG)' % LBCG)
axs.set_xlabel('Redshift')
#axs.set_ylabel(f'{filter} mag')
axs.legend(loc='upper left', fancybox=True, shadow=True)
#axs.set_xlim(0.05, 1.5)
axs.set_ylim(16, 26)
ax.set_ylim(16, 26)
axs.set_yticklabels([])
ax.grid()
axs.grid()
plt.tight_layout()
plt.subplots_adjust(wspace=0.1)
In [11]:
model2 = ezgal.model('/home/boada/Projects/BC2003/bc03/newiseds/1_0gyr_hr_m62_salp.ised')
In [12]:
model2.add_filter('r_MOSAICII.res', name='r')
In [14]:
model2.get_ecorrects(5, filters='r', zs=0.1)
Out[14]:
In [15]:
# desired formation redshift
zf = 3.0
# fetch an array of redshifts out to given formation redshift
zs = model2.get_zs( zf )
In [18]:
plt.plot( zs, model2.get_apparent_mags( zf, filters='sloan_i', zs=zs ), 'k-', label='Sloan i' )
Out[18]:
In [ ]: